/**
 * Created by yubaolin on 2017/9/24.
 */
import ajax from '../ajax'

export default {
  goodsList (success) {
    ajax.get({url: '/api/goods', success})
  },
  getGoodsForName (name, success) {
    ajax.get({url: '/api/goods/goodsForName', params: {name}, success})
  },
  getGoodsList (params, success, fail = null) {
    ajax.get({url: '/api/goods/list', params, success, fail})
  },
  saveGoods (goods, success, fail = null) {
    const method = goods.id === 0 ? 'post' : 'put'
    ajax[method]({url: `/api/goods/${goods.id}`, data: goods, success, fail})
  },
  deleteGoods (id, success, fail = null) {
    ajax.del({url: `/api/goods/${id}`, success, fail})
  },
  deleteGoodsList (ids, success, fail = null) {
    ajax.del({url: `/api/goods/deleteList`, data: {ids}, success, fail})
  },
  getCategoryManufacturer (success, fail = null) {
    ajax.get({url: '/api/goods/categoryManufacturer', success, fail})
  }
}

